package com.mao.security;

import com.mao.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class DefaultPasswordEncoder implements PasswordEncoder {

    public DefaultPasswordEncoder(){this(-1);}
    public DefaultPasswordEncoder(int strength){

    }

    // 进行MD5加密
    @Override
    public String encode(CharSequence rawPassword) {
        return  MD5.encrypt(rawPassword.toString());
    }

    // 进行密码校验
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encodedPassword.equals(MD5.encrypt(rawPassword.toString()));
    }
}
